Skip to content

Conversation

@limbonaut
Copy link
Collaborator

@limbonaut limbonaut commented Aug 29, 2025

This PR adds a new breadcrumb API for a cleaner, more intuitive interface. Previously, add_breadcrumb() method accepted 5 parameters (3 of which were strings), making it confusing to use. The new approach uses a dedicated SentryBreadcrumb class:

var crumb := SentryBreadcrumb.create("Something happened")
crumb.type = "info"
crumb.set_data({"some": "data"})
SentrySDK.add_breadcrumb(crumb)

For simple breadcrumbs, you can use a one-liner:

SentrySDK.add_breadcrumb(SentryBreadcrumb.create("Something happened"))

This change provides better type safety, improved readability, and enables future support for the before_breadcrumb callback.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 3b7e04b

@limbonaut limbonaut force-pushed the feat/breadcrumb-class branch 2 times, most recently from ebc4e09 to 4e0131b Compare August 29, 2025 12:20
@limbonaut limbonaut changed the title feat: Breadcrumb class feat: Introduce Breadcrumb class Sep 1, 2025
@limbonaut limbonaut changed the title feat: Introduce Breadcrumb class feat: Introduce SentryBreadcrumb class Sep 1, 2025
@limbonaut limbonaut marked this pull request as ready for review September 1, 2025 13:37

#include <godot_cpp/classes/ref_counted.hpp>

using namespace godot;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potentially for the future / to be addressed separately: not sure if it has been discussed before, but wouldn't it be better to leave this out of public headers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Godot Engine code base, all the classes live in global namespace. Because we consider supporting compilation as an engine module, I treat this namespace as global as well, at least where it comes to our own class headers that we expose to Godot like SentryBreadcrumb. See #163.


virtual void set_data(const Dictionary &p_data) override { data = p_data; }

virtual Ref<SentryTimestamp> get_timestamp() override { return memnew(SentryTimestamp); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this tend to get called multiple times? would it make sense to allocate the timestamp once as a member if an instance is needed, or return a null ref?

Copy link
Collaborator Author

@limbonaut limbonaut Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't call it at all, only user would do that possibly within before_breadcrumb (correction: not in Disabled backend). I don't think it's worth optimizing. The only reason why we return a non-null is not to break script code.

For example:

var crumb := SentryBreadcrumb.create()
print(crumb.get_timestamp()) #  null access
do_more()

The do_more() part would break in noop builds, while being perfectly fine in normal builds.

@limbonaut limbonaut merged commit c1cbf5f into main Sep 4, 2025
48 checks passed
@limbonaut limbonaut deleted the feat/breadcrumb-class branch September 4, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce SentryBreadcrumb class

3 participants